var vm = new Vue({
	el:"#app",
	data:{
	  textarea1:'',
      period:'',
      verify:'',
      point:'',
      percent:'',
      periodOptions:'',
      verifyOptions:'',
      selfPoints:'',
      textarea2:'',
      item:'',
      delpercent:'',
      capitalize:'',
      score:1
      
	},
	mounted:function(){
		this.$nextTick(function () { // 加个函数可以保证 this和vm是一样 都可以掉用
	        vm.management();
	    })
	},
	computed:{
		final:function(){
			vm.score=Number(vm.point)*Number(vm.percent.substring(0,vm.percent.length-1))/100			
			return vm.score
		}
	},
	methods:{
		management:function () {
		    this.$http.get('../data.json').then(res => { //作用域指向了外层 里面的this就是外面的this
			    vm.periodOptions = res.body.result.periodOptions;
	            vm.verifyOptions = res.body.result.verifyOptions;
	            vm.selfPoints = res.body.result.selfPoints;
		    }); // 调用http方法
		},
//		getGoal(){
//			var percent = document.getElementById("percent").value;
//			var selfpoint = document.getElementById("selfpoint").value;
//			
//		},
//		filters: {
//		  delpercent: function (value) {
//		    if (!value) return ''
//		    //var a = value.split("%");
//		    return value+'test';
//		  }
//		},
		
		onSubmit() {
		  console.log('submit!');
		},
		precentage:function(){
			if(vm.percent.charAt(vm.percent.length-1)=="%"){//初始化数据
				vm.percent=vm.percent.substring(0,vm.percent.length-1)
			}			
			vm.percent=vm.percent.split(" ")
			vm.percent.push("%")
			vm.percent=vm.percent.join('')
		}
	},
	filters: {
		delpercent: function (value) {
		    if (!value) return ''	
		    return value/100;
		}
	},
});
